//
// Created by vcq on 21/2/9.
//
#pragma once
#include "dbng.hpp"
#include "__base_mode__.hpp"
#include "profession.hpp"

using namespace nlohmann;
using namespace std;
struct school {
    int id;
    string name;
    string note;
};
REFLECTION(school,id,name,note)

json mgetSchool(basic_string_view<char> id){
    string sql="select * from `school` where 1=1 ";
    if (!id.empty()) {
        sql += "and id =";
        sql += id;
    }
    Dao dao;
    nlohmann::json article_list,ret,item;
    auto v = dao.query<school>(sql);
    for (auto &o : v) {
        item["id"] = o.id;
        item["name"] = o.name;
        item["note"] = o.note;
        article_list.push_back(item);
    }
    ret["code"] = 0;
    ret["count"] = article_list.size();
    ret["data"] = article_list;
    return ret;
}
void MAddSchool(const struct school& school1){
    Dao dao;
    dao.update_object(school1);
}
void MDeleteSchool(basic_string_view<char> id){
    MDeleteAll("school",id);
}